<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
  <meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" href="<%=path%>/images/favicon.ico" type="image/ico">
<meta name="author" content="guowenjie">
<link href="<%=path%>/css/bootstrap.min.css" rel="stylesheet">
<link href="<%=path%>/css/materialdesignicons.min.css" rel="stylesheet">
<link href="<%=path%>/css/style.min.css" rel="stylesheet">
<link rel="stylesheet" href="<%=path%>/js/ion-rangeslider/ion.rangeSlider.min.css">
<link href="<%=path%>/js/jconfirm/jquery-confirm.min.css" rel="stylesheet">
<link href="<%=path%>/js/bootstrap-datepicker/bootstrap-datepicker3.min.css" rel="stylesheet">
<link href="<%=path%>/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="<%=path%>/css/materialdesignicons.min.css" rel="stylesheet">


<script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
 <script type="text/javascript" src="<%=path%>/js/main.min.js"></script>
<script src="<%=path%>/js/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="<%=path%>/js/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap-table/bootstrap-table.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jconfirm/jquery-confirm.min.js"></script>


</head>
 <body style="background:#FFF">
    
        
           <div class="row">
         <div id="toolbar" class="toolbar-btn-action">
            <div class="col-lg-4">
            <div class="input-group">
                  <input type="text" class="form-control" id="gjz" placeholder="请输入法规关键字">
                  <span class="input-group-btn">
                  <button class="btn btn-default" type="button" onclick="search()">查询</button>
                   </span>
                </div></div></div>
        
          <div class="col-md-12">
           <table id="table" ></table>
        </div>
          
        </div>
            
        
      </body>
       <script type="text/javascript">
      
      





       $('#table').bootstrapTable({
       	classes: 'table table-condensed table-hover',
       	data:[],
       	toolbar: '#toolbar',       // 工具按钮容器	
           dataType : 'json',        // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
           pagination: true,                    // 是否显示分页
           pageNumber: 1,                       // 初始化加载第一页，默认第一页
           pageSize: 10,                        // 每页的记录行数
           sidePagination: "client",            // 分页方式：client客户端分页，server服务端分页
           columns: [{
               field: 'fgid',
               title: '法规序号',
               width:80
               
           },{
               field: 'fgmc',
               title: '法规名称',
               formatter: function (value, row, index) {
               	 var result;
               	 result ='<i class="mdi mdi-file-pdf"><a onclick="showpdf(\''+row.wjlj+'\')">'+value+'</a></i>';
               	 return result;
               }
           }],
        
           onLoadSuccess: function(data){
               $("[data-toggle='tooltip']").tooltip();
           }
       });

       search();
       function search(){
       $.ajax({
       	 type: "post",//方法类型
          dataType: "json",//预期服务器返回的数据类型 jsonp跨域
       	url: "<%=path%>/bg/getfgdata",
       	data:{
       		"fgmc":$("#gjz").val()
       	}, 
       	success: function(req) {	
       		let data = req.data;
       		$("#table").bootstrapTable('refreshOptions',{data:data});	 
       	},error: function(e){ 
       		console.log(e);
       		
       	}
       });
       }




       function showpdf(filename){
       	
       	 
           $.ajax({
       		 type: "post",//方法类型
       	    dataType: "json",//预期服务器返回的数据类型 jsonp跨域
       		url: "<%=path%>/bg/findwj",
       		 data:{
       			"filename":filename
       		}, 
       		success: function(req) {	
       			if(req.msg=="1"){
       				var url = "<%=path%>/bg/pdfwj";
       				 window.open(url);
       			}else{
       				
       				$.alert({
       			        title: '提示',
       			        content: '文件还未上传',
       					buttons: {
       						confirm: {
       							text: '确认',
       							btnClass: 'btn-primary',
       							action: function(){
       			                   
       							}
       						}
       					}
       			    });
       			}
       			 
       		},error: function(){ 
       			
       			
       		}
       	});
        
       }
    	
       
      </script>
       </body>

</html>   